<?php

function http_post($url, $data, $cookie = '') {

		echo 'cookie [SessionId]: ' . $_COOKIE['SessionId'];
		echo '<br/><br/>';


    $serialized_data = http_build_query($data);
		//print_r($serialized_data);


		// !! Guillemets doubles obligatoires
		$header = "Content-type: application/x-www-form-urlencoded\r\n" .
              "Content-Length: " . strlen($serialized_data) . "\r\n" .
							"Cookie: SessionId=0%2CCAD%2C558890\r\n";
		//$header = 'Content-type: application/x-www-form-urlencoded\r\n';

    $options = array(
        'http' => array(
            'method' => 'POST',
            'header' => $header,
            'content' => $serialized_data
        )
    );

    $contexte = stream_context_create($options);
		//print_r($contexte);
		//print_r($url);
		echo '$options: ';
		print_r($options);
		echo '<br/><br/>';

    $content = file_get_contents($url, false, $contexte);
		return $content;
}

function http_post_original($url, $data) {
    $serialized_data = http_build_query($data);
		print_r($data);

    $options = array(
        'http' => array(
            'method' => 'POST',
            'header' => "Content-type: application/x-www-form-urlencoded\r\n" . 'Content-Length: ' . strlen($serialized_data) . "\r\n",
            'content' => $serialized_data
        )
    );

    $contexte = stream_context_create($options);
		print_r($contexte);
		//print_r($url);

    return file_get_contents($url, 0, $contexte);
}

function http_get($url) {
		echo 'cookie [SessionId]: ' . $_COOKIE['SessionId'];
		echo '<br/><br/>';


		// !! Guillemets doubles obligatoires
		$header = "Content-type: application/x-www-form-urlencoded\r\n" .
							"Cookie: SessionId=0%2CCAD%2C558890\r\n";

    $options = array(
        'http' => array(
            'method' => 'GET',
            'header' => $header
        )
    );

    $contexte = stream_context_create($options);

    $content = file_get_contents($url, false, $contexte);
		return $content;
}

function http_get_simple($url) {
    return file_get_contents($url, 0);
}


?>
